/*
 * Copyright (c) 2008 by 1eEurope (Switzerland) AG, Thalwil
 *
 * Customer:	1eEurope (Switzerland) AG
 * Project:		BKS
 * Created:		30.09.2008, WBL
 *
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.WebControls;
using System.Web.UI;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;

namespace By1eEurope.BKS.Controls
{
    /// <summary>
    /// Parameter-Editor class for the BKS Image FieldType
    /// </summary>
    public class ImageFieldEditor : UserControl, IFieldEditor
    {
        protected TextBox Template;
        protected TextBox LongDescReader;

        public void InitializeWithField(SPField field)
        {
            if (!this.IsPostBack)
            {
                ImageField iFld = field as ImageField;
                if (iFld != null)
                {
                    this.Template.Text = iFld.Template;
                    this.LongDescReader.Text = iFld.LongDescReader;
                }
            }
        }

        public void OnSaveChange(SPField field, bool isNew)
        {
            ImageField iFld = field as ImageField;
            if (iFld != null)
            {
                iFld.Template = this.Template.Text;
                iFld.LongDescReader = this.LongDescReader.Text;
            }
        }

        public bool DisplayAsNewSection
        {
            get { return true; }
        }

    }
}
